home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Collections: Amiga Public Domain Connection
/
APDC Disk #005 - Amiga Basic Programs (198x)(Amiga Public Domain Connection)(US)[WB].zip
/
APDC Disk #005 - Amiga Basic Programs (198x)(Amiga Public Domain Connection)(US)[WB].adf
/
Stairs
(
.txt
)
< prev
next >
Wrap
AmigaBASIC Source Code
|
1988-03-13
|
5KB
|
243 lines
'
'Magic Staircase by Gary Cuba (803)776-5295 -- developed
' 1/31/86. All copyrights waived, but mention the author!
'
'Will the tones ever stop ascending?
'
'This is a musical illusion based upon perceptual circularity
' of widely space tones whose volumes are defined as a
' sinesoidal relationship TO their frequency.
'There are 4 tones spaced an octave apart. each tone advances
' in frequency by one half-note until it is within 1/2
' note of the NEXT octave. at this POINT it starts over
' again at its beginning frequency.
'Each tone's volume is set according to its position along a
' sinewave.
'See Roger N. Shepard, 'Circularity in Judgements of Relative
' Pitch', The Journal of the Acoustical Society of America,
' (December 1964).
'
setup:
OPTION BASE 1
GOSUB initialize
GOSUB getpoints
RESTORE
k=1
nw=9
mainloop:
FOR pause =1 TO 2000
NEXT
FOR j=1 TO 4
SOUND f(j,k),20,v(j,k),j-1
NEXT
k=k+1
IF k>12 THEN k=1
IF st=0 THEN
GOTO continue
END IF
FOR i=1 TO 6
AREA(x%(poly(old,i)),y%(poly(old,i)))
NEXT i
AREAFILL 1
continue:
FOR i=1 TO 6
AREA (x%(poly(nw,i)),y%(poly(nw,i)))
NEXT i
AREAFILL 1
old=nw
nw=nw+1
IF nw >24 THEN
nw=9
END IF
FOR pause=1 TO 500
NEXT pause
st=1
GOTO mainloop
initialize:
DIM f(4,12) 'set f(voice,tone #) as frequency
DIM v(4,12) 'set v(voice,tone #) as volume
'these are the frequency steps FOR each voice:
key=0.2
DATA 130.81,138.59,146.83,155.56,164.81,174.61
DATA 185,196,207.65,220,233.08,246.94
DATA 261.63,277.18,293.66,311.13,329.63,349.23
DATA 369.99,392,415.3,440,466.16,493.88
DATA 523.25,554.37,587.33,622.25,659.26,698.46
DATA 739.99,783.99,830.61,880,932.33,977.7
DATA 1046.5,1108.7,1174.7,1244.5,1318.5,1396.9
DATA 1480,1568,1661.2,1760,1864.7,1975.5
FOR i= 1 TO 4
FOR j=1 TO 12
READ f(i,j)
f(i,j)=f(i,j)*key 'lower them a little bit
NEXT
NEXT
'pi defines the length of the volume sinewave (only 1/2
'of a waveform is used).
'inc is the stepping increment for the tone volumes.
'the 240 multiplier supplies sufficient maximum volume.
pi=3.14159: inc=pi/48
ct=0 'voice 1 volumes
FOR i=0 TO pi/4-inc STEP inc
ct=ct+1
v(1,ct)=INT(240*SIN(i))
NEXT
ct=0 'voice 2 volumes
FOR i=pi/4 TO pi/2-inc STEP inc
ct=ct+1
v(2,ct)=INT(240*SIN(i))
NEXT
ct=0 'voice 3 volumes
FOR i=pi/2 TO ((3*pi)/4)-inc STEP inc
ct=ct+1
v(3,ct)=INT(240*SIN(i))
NEXT
ct=0 'voice 4 volumes
FOR i=(3*pi)/4 TO pi-inc STEP inc
ct=ct+1
v(4,ct)=INT(240*SIN(i))
NEXT
'the sound waveforms (disk file):
DIM timbre%(256)
OPEN "tone1" FOR INPUT AS #1
FOR k=1 TO 256
INPUT #1,timbre%(k)
NEXT k
CLOSE #1
WAVE 0,timbre%
WAVE 1,timbre%
WAVE 2,timbre%
WAVE 3,timbre%
RETURN
getpoints: 'picture stuff
DIM poly(24,16)
DIM x%(68)
DIM y%(68)
DIM x(68)
DIM y(68)
DATA 10,120,10,45,25,55,25,50,40,60,40,55,55,65,55,60
DATA 70,70,70,65,85,75,85,70,100,80,100,75,115,85,115,190
DATA 160,160,160,45,145,54,145,60,130,70,130,75,115,66
DATA 115,60,130,50,130,45,145,35,145,30,130,39,115,30
DATA 130,21,130,15,115,25,115,20,100,30,100,25,85,35
DATA 85,30,70,40,70,35,55,45,55,40,47.5,45,40,40,52,47.5
DATA 55,45,67,52.5,70,50,82,57.5,85,55,97,62.5,100,60
DATA 112,67.5,35,42.5,25,35,29,37.5,40,30,43,32.5,55,25
DATA 58,27.5,70,20,74,22.5,85,15,88,17.5,100,10,103,12.5,115,5
FOR i=1 TO 67
READ x(i),y(i)
x%(i)=(x(i)+50)*2.5
y%(i)=y(i)*0.9
NEXT i
DATA 1,2,3,4,5,6,7,8,9,16
FOR i=1 TO 10
READ poly(1,i)
AREA (x%(poly(1,i)),y%(poly(1,i)))
NEXT i
AREAFILL
DATA 9,10,11,12,13,14,15,16
FOR i=1 TO 8
READ poly(2,i)
AREA (x%(poly(2,i)),y%(poly(2,i)))
NEXT i
AREAFILL
DATA 23,24,21,22
FOR i=1 TO 4
READ poly(3,i)
AREA (x%(poly(3,i)),y%(poly(3,i)))
NEXT i
AREAFILL
DATA 24,25,20,19,26,29,30
FOR i=1 TO 7
READ poly(4,i)
AREA (x%(poly(4,i)),y%(poly(4,i)))
NEXT i
AREAFILL
COLOR 3
DATA 37,38,39,40,41,42,43,45,46,47,48,49,50,51,52
FOR i=1 TO 15
READ poly(5,i)
AREA (x%(poly(5,i)),y%(poly(5,i)))
NEXT i
AREAFILL
DATA 37,36,35,34,33,32,31,30,23,53,52
FOR i=1 TO 11
READ poly(6,i)
AREA (x%(poly(6,i)),y%(poly(6,i)))
NEXT i
AREAFILL
DATA 26,27,28,29
FOR i=1 TO 4
READ poly(7,i)
AREA (x%(poly(7,i)),y%(poly(7,i)))
NEXT i
AREAFILL
DATA 15,16,17,18,19,20,21,22
FOR i=1 TO 8
READ poly(8,i)
AREA (x%(poly(8,i)),y%(poly(8,i)))
NEXT i
AREAFILL
COLOR 2
DATA 2,3,4,54,55,55,4,44,45,6,5,5,6,46,47,8,7,7
DATA 8,48,49,10,9,9,10,50,51,12,11,11,12,52,53,14,13,13
DATA 14,23,22,15,15,15,20,21,24,25,25,25,18,19,26,27,27,27
DATA 28,29,30,31,31,31,32,33,34,66,67,67,34,35,36,64,65,65
DATA 36,37,38,62,63,63,38,39,40,60,61,61
DATA 40,41,42,58,59,59,42,43,44,54,56,57
FOR i=9 TO 24
FOR j=1 TO 6
READ poly(i,j)
AREA (x%(poly(i,j)),y%(poly(i,j)))
NEXT j
AREAFILL
NEXT i
COLOR 1
LOCATE 1,1
PRINT "A polyperceptual illusion"
LOCATE 2,3
PRINT "...by Gary Cuba"
LOCATE 16,5
PRINT "Will the tones ever"
LOCATE 17,7
PRINT "stop ascending?"
LOCATE 19,12
PRINT "Where do the steps lead?"
RETURN